<?php
class Macys_Base_Cookie {

	private $httpClient;
	private $cookieInfo;
	private $session;
	
	public function __construct() {
		$this->session = new Macys_Base_Session();
		$this->setHttpClient();
	}

	public function getInstance() {

	}

	public function setHttpClient($client = null) {
		if($client instanceof Zend_Http_Client) {
			$this->httpClient = $client;
		}
		else {
			$this->httpClient = Zend_Service_Abstract::getHttpClient();
		}
	}

	public function getCookieJar() {
		$cookie = $this->httpClient->getCookieJar();
		if(!empty($cookie)) {
			$this->cookieInfo = $cookie->getAllCookies(Zend_Http_CookieJar::COOKIE_OBJECT);
			if(!empty($this->cookieInfo)) {
				foreach ($this->cookieInfo as $key => $value) {
					if($value instanceof Zend_Http_Cookie) {
						$this->log->debug("From Config Cookie Name : " . $this->cookieName);
						$this->log->debug("Cookie Identified with name :: " . $value->getName());
						if($value->getName() == $this->cookieName) {
							$uid = $value->getValue();
							$this->log->debug("User Id found in cookie :: " . $this->cookieName . "=" . $uid );
							$this->setUserId($uid);
							$this->sessionData('cookieData', $value);
						}
					}
				}
			}
		}
	}

	public function setCookies() {

	}

	/**
	 * Saves this Class's info to Session
	 * Provides connectivity to Session class
	 * @param string $key
	 * @param Mixed $value
	 */
	private function sessionData($key, $value = null) {
		return $this->session->sessionData(self::SESSION_NAME, $key, $value);
	}
}